package com.wy.framework.actions.feedback;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ExceptionMapping;
import org.apache.struts2.convention.annotation.ExceptionMappings;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.itextpdf.text.log.SysoCounter;
import com.wy.framework.actions.AbstractBaseAction;
import com.wy.framework.constants.RtnCodeConstant;
import com.wy.framework.dao.ErrorSqlException;
import com.wy.framework.exceptions.ServiceException;
import com.wy.framework.pojos.TSysOrgroles;
import com.wy.framework.pojos.TSysRoleinfo;
import com.wy.framework.services.feedback.FeedBackService;
import com.wy.framework.services.permission.RoleManageService;

/**
 * 
 * 项目名称：openportal
 * 类名称：FeedBackAction
 * 类描述：反馈管理
 * 创建人：高振泰
 * 创建时间：2016-1-7 上午11:16:05
 * 修改人：
 * 修改时间：2016-1-7 上午11:16:05
 * 版本信息：@version 1.0
 * Copyright (c) 2016万雍科技（上海）有限公司-版权所有  
 * 修改备注：
 * @version
 */
@ParentPackage("json")
@Namespace("/feedback")
@ExceptionMappings({ @ExceptionMapping(exception = "java.lange.RuntimeException", result = "error") })
public class FeedBackAction extends AbstractBaseAction {
	private static final long serialVersionUID = 1L;
	private static Log logger = LogFactory.getLog(FeedBackAction.class);

	private List<Map> rows;
	
	@Autowired
	private FeedBackService feedBackService;
	
	@Action(value = "help", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false","root","rows"}) })
	public String help() throws ServiceException{
		rows=feedBackService.queryHelpList();
		return SUCCESS;
	}
	
	@Action(value = "helpDetail", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false","root","rows"}) })
	public String helpDetail()throws ServiceException{
		String helpinfoId=ServletActionContext.getRequest().getParameter("helpinfoId");
		rows=feedBackService.queryHelpInfo(helpinfoId);
		return SUCCESS;
	}
	
	public List<Map> getRows() {
		return rows;
	}

	public int getTotal() {
		if (rows == null) {
			return 0;
		} else {
			return rows.size();
		}
	}
	

}
